import 'dart:typed_data';

import 'package:wechat_assets_picker/wechat_assets_picker.dart';

import '../provider.dart';
import '../widget/dialogs.dart';

class UserFeedbackModel extends JRChangeNotifier {
  static const TAG = "UserFeedbackModel";

  late List<String> reportReasons = [];
  late List reportImages = [];
  late String reason = "";
  late String content = "";
  int? userId, roomId;

  UserFeedbackModel() {}

  List<AssetEntity>? result;

  void uploadPicture(context, int i) async {
    result = await AssetPicker.pickAssets(
      context,
      pickerConfig: AssetPickerConfig(
        maxAssets: 1,
        requestType: RequestType.common,
        specialPickerType: SpecialPickerType.noPreview,
        previewThumbnailSize: const ThumbnailSize(200, 200),
        textDelegate: const AssetPickerTextDelegate(),
      ),
    );
    showLoadingDialog();
    for (AssetEntity element in result ?? []) {
      if (element.type == AssetType.video) {
        Uint8List? thumbData = await element.thumbnailData;
        String? thumbUrl;
        // if(thumbData != null){
        //     thumbUrl = await UserInfoEditApi.instance.saveThumb(thumbData);
        // }
        // var value = await UserInfoEditApi.instance.saveVideo((await element.file)!.path);
        // if (value != null) {
        //   reportImages.add(
        //     {
        //       "type": AssetType.video,
        //       "thumb": thumbData,
        //       "data": value,
        //       if(thumbUrl != null) "thumbUrl": thumbUrl
        //     },
        //   );
        //   notifyListeners();
        // }
      } else if (element.type == AssetType.image) {
        // var value = await UserInfoEditApi.instance.savePicture((await element.file)!);
        // if (value != null) {
        //   reportImages.add(
        //     {
        //       "type": AssetType.image,
        //       "data": value,
        //     },
        //   );
        //   notifyListeners();
        // }
      }
    }
    dismissLoadingDialog();
  }
}
